package utils;

public class Sphere {

	private double x,y,z,radius;
	private String couleur=""; 

	/**
	 * @return the x
	 */
	public double getX() {
		return x;
	}

	/**
	 * @return the y
	 */
	public double getY() {
		return y;
	}

	/**
	 * @return the z
	 */
	public double getZ() {
		return z;
	}

	/**
	 * @return the radius
	 */
	public double getRadius() {
		return radius;
	}
	
	public void setRadius(double r){this.radius=r;}
	
	public double distance(Sphere s){
		double x1=this.x-s.x; 
		double y1=this.y-s.y; 
		double z1=this.z-s.z; 
		return Math.sqrt(x1*x1+y1*y1+z1*z1); 
	}
	

	/**
	 * @param x
	 * @param y
	 * @param z
	 * @param radius
	 */
	public Sphere(double x, double y, double z, double radius) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
		this.radius = radius;
	} 
	
	public Sphere(double x, double y, double z, double radius,String c) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
		this.radius = radius;
		this.couleur=c; 
	} 
	/** Return true if Sphere s and this intersect */
	public boolean intersects(Sphere s){
		return(this.distance(s)<(this.radius+s.radius)); 
	}
	
	public String toString(){
		if(this.couleur.equals("")){
		int texture=(int)(-Math.log(radius)/Math.log(2)); 
		String s="sphere{<"+x+","+y+","+z+">,"+radius+" texture{Texture"+texture+"} finish{Finish"+texture+"}}";
		return s; 
		}
		else{
			//String s="sphere{<"+x+","+y+","+z+">,"+radius+" texture{pigment{color "+this.couleur+"}} finish{reflection 0.3}}";
			String s="sphere{<"+x+","+y+","+z+">,"+radius+" texture{T_Chrome_5E} finish{Metallic_Finish}}";
			return s; 	
		}
			
	}
	
	
}
